import { CoolCommException } from "@cool-midway/core";
import { Rule, RuleType } from "@midwayjs/validate";
import { ScheduleSource, ScheduleStatus } from "../entity/schedule";



export class AssertScheduleDTO {
    // 如果capacityId为空，则表示是给当前登录的服务人员排班
    @Rule(RuleType.number().optional())
    capacityId?: number

    @Rule(
        RuleType.array().items(
            RuleType.object().keys({
                date: RuleType.date().required().error(new CoolCommException('日期不能为空')),
                status: RuleType.allow(ScheduleStatus.UNKNOWN, ScheduleStatus.FREE, ScheduleStatus.BUSY).required().error(new CoolCommException('状态不能为空')),
                remark: RuleType.string().max(255).optional().allow('').error(new CoolCommException('备注不能为空')),
            })
        )
    )
    dateList: {
        date: Date
        status: ScheduleStatus,
        remark: string,
    }[]

    @Rule(RuleType.allow(ScheduleSource.CAR, ScheduleSource.PROVIDER).default(ScheduleSource.CAR).error(new CoolCommException('来源不能为空')))
    source: ScheduleSource;
}